<?php 
include './include/conf.php';

$nom = (isset($_POST['nom'])) ? $_POST['nom'] : NULL;
$prenom = (isset($_POST['prenom'])) ? $_POST['prenom'] : NULL;

$select_id = $pdo->prepare("select id_adherent as id from adherent where adherent.nom='$nom' and adherent.prenom='$prenom'");
$select_id->execute();
$id_adherent = $select_id->fetch()->id;

$select = $pdo->prepare("SELECT nom FROM champ where exists (SELECT * FROM anonymat where champ.id_champ = anonymat.id_champ and anonymat.id_adherent='$id_adherent' and anonymat.visible =1)");
$select->execute();

$tabRetour = array();

if($select->rowCount() > 0)
{
	$donnees = array();
	while($check = $select->fetch())
	{
		$donnees[] = $check;
	}
	$tabRetour['listeCheckBox'] = $donnees;
}
else
{
	$tabRetour['listeCheckBox'] = "";
}

$select = $pdo->prepare("SELECT * FROM Adherent where adherent.id_adherent='$id_adherent'");
$select->execute();

if($select->rowCount() > 0)
{
	$donnees = array();
	while($user = $select->fetch())
	{
		$donnees[] = $user;	
	}
	$tabRetour['infoAdherent'] = $donnees;
}
else
{
	$tabRetour['infoAdherent'] = "";
}

	echo json_encode($tabRetour);

?>